import * as Joi from '@hapi/joi';

export const configValidationSchema = Joi.object({
  NODE_ENV: Joi.string()
    .valid('development', 'production', 'test')
    .default('development'),
  PORT: Joi.number().min(1).max(65535).default(3000),

  // 数据库配置验证
  DB_HOST: Joi.string().default('localhost'),
  DB_PORT: Joi.number().min(1).max(65535).default(3306),
  DB_USERNAME: Joi.string().min(1).required(),
  DB_PASSWORD: Joi.string().min(1).required(),
  DB_DATABASE: Joi.string().min(1).required(),

  // JWT配置验证
  JWT_SECRET: Joi.string().min(32).required(),
  JWT_EXPIRES_IN: Joi.string()
    .pattern(/^[0-9]+[smhd]$/)
    .default('24h'),

  // 上传配置
  UPLOAD_PATH: Joi.string().default('./uploads'),
  UPLOAD_MAX_SIZE: Joi.number().default(5242880), // 5MB
});
